public class ThreadDemo9 {
    public static void main(String[] args) {
        Object object =new Object();
        Thread t =new Thread(() ->{
            synchronized (object){
                System.out.println(Thread.currentThread().getName() + " t wait之前.");

                try {
                    object.wait();

                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }
                System.out.println(Thread.currentThread().getName() + " t wait之后.");
            }
        });
        Thread t1 =new Thread(() ->{
            try {
                Thread.sleep(2000);
                synchronized (object){
                    System.out.println(Thread.currentThread().getName() + " t1 notify之前");
                    object.notify();
                    System.out.println(Thread.currentThread().getName() + " t1 notify之后");

                }
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }

        });
        t.start();
        t1.start();
    }
}
